using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace OrigPacman
{
    public class Score
    {
        #region Variables
        protected Rectangle container;
        protected int total;
        protected SpriteFont font;
        protected Vector2 position;
        protected int lives;
        protected bool complete;
        #endregion

        #region Properties
        public int Total
        {
            get { return total; }
            set { total = value; }
        }
        public bool Complete
        {
            get { return complete; }
            set { complete = value; }
        }
        public int Lives
        {
            get { return lives; }
            set { lives = value; }
        }
        public SpriteFont Font
        {
            get { return font; }
            set { font = value; }
        }
        public Vector2 Position
        {
            get { return position; }
            set
            {
                position = value;
                container.X = (int)position.X;
                container.Y = (int)position.Y;
            }
        }
        public Rectangle Bounds
        {
            get { return container; }
            set
            {
                container = value;
                position = new Vector2(container.X, container.Y);
            }
        }
        #endregion

        public Score()
        {
            container = new Rectangle(10, 10, 300, 200);
            total = 0;
        }

        public void Draw(ref SpriteBatch sprite)
        {
            int margin = 5; 
            if(lives > 0) {
                sprite.DrawString(font, "Score: " + total, 
                    new Vector2(container.Left + margin, container.Top+ margin), Color.Snow);
                sprite.DrawString(font, "Lives: " + lives,
                    new Vector2(container.Right - container.Width/2 + margin, container.Top + margin), Color.Snow);
                if (complete)
                {
                    Rectangle completed = new Rectangle(156, 156, 200, 200);
                    sprite.DrawString(font, "Level Complete!",
                    new Vector2(completed.Left + completed.Width / 2 - margin,
                    completed.Top + completed.Width / 2 - margin), Color.Orange);
                }
            }
            else
            {
                container = new Rectangle(156, 156, 200, 200);
                sprite.DrawString(font, "GAME OVER",
                new Vector2(container.Left + container.Width / 2 - margin,
                    container.Top + container.Width / 2 - margin), Color.Red);
            }
        }

        public void Update(Pacman pacman)
        {
            total = pacman.Score;
            lives = pacman.Lives;
        }
    }
}
